/** 
  Copyright (c) 2008, 2009 Claudio Imbrenda
  This program is released under the terms of the
  GNU GPL version 3 or later.
*/
package interfaccia;

import java.awt.event.*;
import macchina.*;
import macchina.nastri.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.BorderLayout;


public class MRPanel extends javax.swing.JPanel 
          implements MRPanelInterface {
  
      
  private static ResourceBundle bundle_interfaccia = 
          ResourceBundle.getBundle("interfaccia/Bundle_interfaccia");  
  
    
  private List<ActionListener> ascoltatori = new ArrayList<ActionListener>();
    
  private JCheckBox[] viA=new JCheckBox[18];
  private JCheckBox[] tiA=new JCheckBox[15];
  private JCheckBox[] tmA=new JCheckBox[18];

  private ImageIcon handle_center;
  private ImageIcon handle_left;
  private ImageIcon handle_right;

  public void addActionListener(ActionListener a){
    ascoltatori.add(a);
  }
  
  public void removeActionListener(ActionListener a){
    ascoltatori.remove(a);
  }
  
  private void fireChange(int what){
    final ActionEvent ae=new ActionEvent(this,what,null);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        for(ActionListener a:ascoltatori)
        a.actionPerformed(ae);
      }
    });
  }
  
  /** Creates new form MRPanel */
    public MRPanel() {
        initComponents();
        
        viA[0]=chkVI0;viA[1]=chkVI1;viA[2]=chkVI2;
        viA[3]=chkVI3;viA[4]=chkVI4;viA[5]=chkVI5;
        viA[6]=chkVI6;viA[7]=chkVI7;viA[8]=chkVI8;
        viA[9]=chkVI9;viA[10]=chkVI10;viA[11]=chkVI11;
        viA[12]=chkVI12;viA[13]=chkVI13;viA[14]=chkVI14;
        viA[15]=chkVI15;viA[16]=chkVI16;viA[17]=chkVI17;
        
        tiA[0]=chkTI0;tiA[1]=chkTI1;tiA[2]=chkTI2;
        tiA[3]=chkTI3;tiA[4]=chkTI4;tiA[5]=chkTI5;
        tiA[6]=chkTI6;tiA[7]=chkTI7;tiA[8]=chkTI8;
        tiA[9]=chkTI9;tiA[10]=chkTI10;tiA[11]=chkTI11;
        tiA[12]=chkTI12;tiA[13]=chkTI13;tiA[14]=chkTI14;
        
        tmA[0]=chkTM0;tmA[1]=chkTM1;tmA[2]=chkTM2;
        tmA[3]=chkTM3;tmA[4]=chkTM4;tmA[5]=chkTM5;
        tmA[6]=chkTM6;tmA[7]=chkTM7;tmA[8]=chkTM8;
        tmA[9]=chkTM9;tmA[10]=chkTM10;tmA[11]=chkTM11;
        tmA[12]=chkTM12;tmA[13]=chkTM13;tmA[14]=chkTM14;
        tmA[15]=chkTM15;tmA[16]=chkTM16;tmA[17]=chkTM17;
        
        ActionListener tmal = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            _updatetm();
            fireChange(FLAG_TM);
          }
        };
        ActionListener tial = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            _updateti();
            fireChange(FLAG_TI);
          }
        };
        
        for(int cx=0;cx<18;cx++)tmA[cx].addActionListener(tmal);
        for(int cx=0;cx<15;cx++)tiA[cx].addActionListener(tial);


        ImageIcon switch_on = new ImageIcon(getClass().getResource("/interfaccia/switch-on.png"));
        ImageIcon switch_off = new ImageIcon(getClass().getResource("/interfaccia/switch-off.png"));
        ImageIcon light_on = new ImageIcon(getClass().getResource("/interfaccia/light-on.png"));
        ImageIcon light_off = new ImageIcon(getClass().getResource("/interfaccia/light-off.png"));
        ImageIcon button = new ImageIcon(getClass().getResource("/interfaccia/button.png"));

        handle_center = new ImageIcon(getClass().getResource("/interfaccia/handle.png"));
        handle_left = new ImageIcon(getClass().getResource("/interfaccia/handle-left.png"));
        handle_right = new ImageIcon(getClass().getResource("/interfaccia/handle-right.png"));

        switch_off=MRMainFrame.resizeIcon(switch_off, 16, 51);
        switch_on=MRMainFrame.resizeIcon(switch_on, 16, 51);
        light_off=MRMainFrame.resizeIcon(light_off, 16, 16);
        light_on=MRMainFrame.resizeIcon(light_on, 16, 16);
        button=MRMainFrame.resizeIcon(button, 24, 24);
        handle_left=MRMainFrame.resizeIcon(handle_left, 26, 26);
        handle_right=MRMainFrame.resizeIcon(handle_right, 26, 26);
        handle_center=MRMainFrame.resizeIcon(handle_center, 26, 26);

        for(int cx=0;cx<18;cx++){
            tmA[cx].setIcon(switch_off);
            tmA[cx].setSelectedIcon(switch_on);
        }
        for(int cx=0;cx<15;cx++){
            tiA[cx].setIcon(switch_off);
            tiA[cx].setSelectedIcon(switch_on);
        }
        
        for(int cx=0;cx<18;cx++){
            viA[cx].setIcon(light_off);
            viA[cx].setSelectedIcon(light_on);
            viA[cx].setDisabledIcon(light_off);
            viA[cx].setDisabledSelectedIcon(light_on);
        }

        chkIsRunning.setIcon(light_off);
        chkIsRunning.setSelectedIcon(light_on);
        chkIsRunning.setDisabledIcon(light_off);
        chkIsRunning.setDisabledSelectedIcon(light_on);


        btnExternal.setIcon(switch_on);
        btnExternal.setSelectedIcon(switch_off);
        btnAC.setIcon(switch_off);
        btnAC.setSelectedIcon(switch_on);

        btnStart.setIcon(button);
        btnMode.setIcon(handle_center);
        
        String wallpapero = System.getProperty("macchinaridotta.wallpaper");
        if(wallpapero!=null){
            lblDesktopPicture.setIcon(new ImageIcon(wallpapero));
        }
    }

    public void setTapeDisplay(JComponent tdis){
        jPanel1.add(tdis, BorderLayout.CENTER);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    modalitaGroup = new javax.swing.ButtonGroup();
    jPanel3 = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jLabel12 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    jLabel15 = new javax.swing.JLabel();
    jLabel16 = new javax.swing.JLabel();
    jLabel17 = new javax.swing.JLabel();
    jLabel18 = new javax.swing.JLabel();
    jLabel20 = new javax.swing.JLabel();
    chkTM17 = new javax.swing.JCheckBox();
    chkTM16 = new javax.swing.JCheckBox();
    chkTM15 = new javax.swing.JCheckBox();
    chkTM14 = new javax.swing.JCheckBox();
    chkTM13 = new javax.swing.JCheckBox();
    chkTM12 = new javax.swing.JCheckBox();
    chkTM11 = new javax.swing.JCheckBox();
    chkTM10 = new javax.swing.JCheckBox();
    chkTM9 = new javax.swing.JCheckBox();
    chkTM8 = new javax.swing.JCheckBox();
    chkTM7 = new javax.swing.JCheckBox();
    chkTM6 = new javax.swing.JCheckBox();
    chkTM5 = new javax.swing.JCheckBox();
    chkTM4 = new javax.swing.JCheckBox();
    chkTM3 = new javax.swing.JCheckBox();
    chkTM2 = new javax.swing.JCheckBox();
    chkTM1 = new javax.swing.JCheckBox();
    chkTM0 = new javax.swing.JCheckBox();
    jLabel21 = new javax.swing.JLabel();
    chkTI14 = new javax.swing.JCheckBox();
    chkTI13 = new javax.swing.JCheckBox();
    chkTI12 = new javax.swing.JCheckBox();
    chkTI11 = new javax.swing.JCheckBox();
    chkTI10 = new javax.swing.JCheckBox();
    chkTI9 = new javax.swing.JCheckBox();
    chkTI8 = new javax.swing.JCheckBox();
    chkTI7 = new javax.swing.JCheckBox();
    chkTI6 = new javax.swing.JCheckBox();
    chkTI5 = new javax.swing.JCheckBox();
    chkTI4 = new javax.swing.JCheckBox();
    chkTI3 = new javax.swing.JCheckBox();
    chkTI2 = new javax.swing.JCheckBox();
    chkTI1 = new javax.swing.JCheckBox();
    chkTI0 = new javax.swing.JCheckBox();
    jLabel25 = new javax.swing.JLabel();
    chkVI17 = new javax.swing.JCheckBox();
    chkVI16 = new javax.swing.JCheckBox();
    chkVI15 = new javax.swing.JCheckBox();
    chkVI14 = new javax.swing.JCheckBox();
    chkVI13 = new javax.swing.JCheckBox();
    chkVI12 = new javax.swing.JCheckBox();
    chkVI11 = new javax.swing.JCheckBox();
    chkVI10 = new javax.swing.JCheckBox();
    chkVI9 = new javax.swing.JCheckBox();
    chkVI8 = new javax.swing.JCheckBox();
    chkVI7 = new javax.swing.JCheckBox();
    chkVI6 = new javax.swing.JCheckBox();
    chkVI5 = new javax.swing.JCheckBox();
    chkVI4 = new javax.swing.JCheckBox();
    chkVI3 = new javax.swing.JCheckBox();
    chkVI2 = new javax.swing.JCheckBox();
    chkVI1 = new javax.swing.JCheckBox();
    chkVI0 = new javax.swing.JCheckBox();
    chkIsRunning = new javax.swing.JCheckBox();
    btnExternal = new javax.swing.JCheckBox();
    btnAC = new javax.swing.JCheckBox();
    jLabel19 = new javax.swing.JLabel();
    jPanel6 = new javax.swing.JPanel();
    jLabel22 = new javax.swing.JLabel();
    jLabel23 = new javax.swing.JLabel();
    btnStart = new javax.swing.JButton();
    jPanel5 = new javax.swing.JPanel();
    btnMode = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    lblDesktopPicture = new javax.swing.JLabel();

    setLayout(new java.awt.BorderLayout());

    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("TL"));
    jPanel3.setLayout(new java.awt.BorderLayout());
    add(jPanel3, java.awt.BorderLayout.CENTER);

    jPanel2.setLayout(new java.awt.BorderLayout());

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("LF"));
    jPanel1.setLayout(new java.awt.BorderLayout());
    jPanel2.add(jPanel1, java.awt.BorderLayout.WEST);

    jPanel4.setLayout(new java.awt.BorderLayout());

    jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("QCM"));
    jPanel8.setLayout(new java.awt.GridBagLayout());

    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("17");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel1, gridBagConstraints);

    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel2.setText("16");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel2, gridBagConstraints);

    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("15");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel3, gridBagConstraints);

    jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel4.setText("14");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel4, gridBagConstraints);

    jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel5.setText("13");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 6;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel5, gridBagConstraints);

    jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel6.setText("12");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 7;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel6, gridBagConstraints);

    jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel7.setText("11");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 8;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel7, gridBagConstraints);

    jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel8.setText("10");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 9;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel8, gridBagConstraints);

    jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel9.setText("9");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 10;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel9, gridBagConstraints);

    jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel10.setText("8");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 11;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel10, gridBagConstraints);

    jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel11.setText("7");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 12;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel11, gridBagConstraints);

    jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel12.setText("6");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 13;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel12, gridBagConstraints);

    jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel13.setText("5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 14;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel13, gridBagConstraints);

    jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel14.setText("4");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 15;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel14, gridBagConstraints);

    jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel15.setText("3");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 16;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel15, gridBagConstraints);

    jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel16.setText("2");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 17;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel16, gridBagConstraints);

    jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel17.setText("1");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 18;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(jLabel17, gridBagConstraints);

    jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel18.setText("0");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 19;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 12;
    gridBagConstraints.ipady = 6;
    jPanel8.add(jLabel18, gridBagConstraints);

    jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jLabel20.setText("TM");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 20;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 9;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel8.add(jLabel20, gridBagConstraints);

    chkTM17.setToolTipText(bundle_interfaccia.getString("Tastiera_Memoria")); // NOI18N
    chkTM17.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM17.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM17, gridBagConstraints);

    chkTM16.setToolTipText("Tastiera Memoria");
    chkTM16.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM16.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM16.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM16, gridBagConstraints);

    chkTM15.setToolTipText("Tastiera Memoria");
    chkTM15.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM15.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM15, gridBagConstraints);

    chkTM14.setToolTipText("Tastiera Memoria");
    chkTM14.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM14.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM14, gridBagConstraints);

    chkTM13.setToolTipText("Tastiera Memoria");
    chkTM13.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM13.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 6;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM13, gridBagConstraints);

    chkTM12.setToolTipText("Tastiera Memoria");
    chkTM12.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM12.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 7;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM12, gridBagConstraints);

    chkTM11.setToolTipText("Tastiera Memoria");
    chkTM11.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM11.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 8;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM11, gridBagConstraints);

    chkTM10.setToolTipText("Tastiera Memoria");
    chkTM10.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM10.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 9;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM10, gridBagConstraints);

    chkTM9.setToolTipText("Tastiera Memoria");
    chkTM9.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM9.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 10;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM9, gridBagConstraints);

    chkTM8.setToolTipText("Tastiera Memoria");
    chkTM8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM8.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 11;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM8, gridBagConstraints);

    chkTM7.setToolTipText("Tastiera Memoria");
    chkTM7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM7.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 12;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM7, gridBagConstraints);

    chkTM6.setToolTipText("Tastiera Memoria");
    chkTM6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM6.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 13;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM6, gridBagConstraints);

    chkTM5.setToolTipText("Tastiera Memoria");
    chkTM5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM5.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 14;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM5, gridBagConstraints);

    chkTM4.setToolTipText("Tastiera Memoria");
    chkTM4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM4.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 15;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM4, gridBagConstraints);

    chkTM3.setToolTipText("Tastiera Memoria");
    chkTM3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM3.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 16;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM3, gridBagConstraints);

    chkTM2.setToolTipText("Tastiera Memoria");
    chkTM2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM2.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 17;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM2, gridBagConstraints);

    chkTM1.setToolTipText("Tastiera Memoria");
    chkTM1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM1.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 18;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM1, gridBagConstraints);

    chkTM0.setToolTipText("Tastiera Memoria");
    chkTM0.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTM0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTM0.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 19;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTM0, gridBagConstraints);

    jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jLabel21.setText("TI");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 20;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 9;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel8.add(jLabel21, gridBagConstraints);

    chkTI14.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI14.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI14.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI14, gridBagConstraints);

    chkTI13.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI13.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI13.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 6;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI13, gridBagConstraints);

    chkTI12.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI12.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI12.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 7;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI12, gridBagConstraints);

    chkTI11.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI11.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI11.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 8;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI11, gridBagConstraints);

    chkTI10.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI10.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI10.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 9;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI10, gridBagConstraints);

    chkTI9.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI9.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI9.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 10;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI9, gridBagConstraints);

    chkTI8.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI8.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 11;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI8, gridBagConstraints);

    chkTI7.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI7.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 12;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI7, gridBagConstraints);

    chkTI6.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI6.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 13;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI6, gridBagConstraints);

    chkTI5.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI5.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 14;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI5, gridBagConstraints);

    chkTI4.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI4.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 15;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI4, gridBagConstraints);

    chkTI3.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI3.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 16;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI3, gridBagConstraints);

    chkTI2.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI2.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 17;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI2, gridBagConstraints);

    chkTI1.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI1.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 18;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI1, gridBagConstraints);

    chkTI0.setToolTipText(bundle_interfaccia.getString("Tastiera_Istruzioni")); // NOI18N
    chkTI0.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkTI0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkTI0.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 19;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(chkTI0, gridBagConstraints);

    jLabel25.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jLabel25.setText("IV");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 20;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 9;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(jLabel25, gridBagConstraints);

    chkVI17.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI17.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI17.setEnabled(false);
    chkVI17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI17.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI17, gridBagConstraints);

    chkVI16.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI16.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI16.setEnabled(false);
    chkVI16.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI16.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI16, gridBagConstraints);

    chkVI15.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI15.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI15.setEnabled(false);
    chkVI15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI15.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI15, gridBagConstraints);

    chkVI14.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI14.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI14.setEnabled(false);
    chkVI14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI14.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI14, gridBagConstraints);

    chkVI13.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI13.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI13.setEnabled(false);
    chkVI13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI13.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 6;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI13, gridBagConstraints);

    chkVI12.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI12.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI12.setEnabled(false);
    chkVI12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI12.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 7;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI12, gridBagConstraints);

    chkVI11.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI11.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI11.setEnabled(false);
    chkVI11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI11.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 8;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI11, gridBagConstraints);

    chkVI10.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI10.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI10.setEnabled(false);
    chkVI10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI10.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 9;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI10, gridBagConstraints);

    chkVI9.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI9.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI9.setEnabled(false);
    chkVI9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI9.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 10;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI9, gridBagConstraints);

    chkVI8.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI8.setEnabled(false);
    chkVI8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI8.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 11;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI8, gridBagConstraints);

    chkVI7.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI7.setEnabled(false);
    chkVI7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI7.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 12;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI7, gridBagConstraints);

    chkVI6.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI6.setEnabled(false);
    chkVI6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI6.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 13;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI6, gridBagConstraints);

    chkVI5.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI5.setEnabled(false);
    chkVI5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI5.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 14;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI5, gridBagConstraints);

    chkVI4.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI4.setEnabled(false);
    chkVI4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI4.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 15;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI4, gridBagConstraints);

    chkVI3.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI3.setEnabled(false);
    chkVI3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI3.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 16;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI3, gridBagConstraints);

    chkVI2.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI2.setEnabled(false);
    chkVI2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI2.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 17;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI2, gridBagConstraints);

    chkVI1.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI1.setEnabled(false);
    chkVI1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI1.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 18;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI1, gridBagConstraints);

    chkVI0.setToolTipText(bundle_interfaccia.getString("Visualizzatore")); // NOI18N
    chkVI0.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVI0.setEnabled(false);
    chkVI0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    chkVI0.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 19;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    jPanel8.add(chkVI0, gridBagConstraints);

    chkIsRunning.setText("IM");
    chkIsRunning.setToolTipText("Indicatore Attività");
    chkIsRunning.setContentAreaFilled(false);
    chkIsRunning.setEnabled(false);
    chkIsRunning.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    chkIsRunning.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    jPanel8.add(chkIsRunning, gridBagConstraints);

    btnExternal.setToolTipText("Istruzioni Esterne");
    btnExternal.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    btnExternal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    btnExternal.setMargin(new java.awt.Insets(0, 0, 0, 0));
    btnExternal.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnExternalActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(btnExternal, gridBagConstraints);

    btnAC.setToolTipText("Arresto Condizionale");
    btnAC.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    btnAC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    btnAC.setMargin(new java.awt.Insets(0, 0, 0, 0));
    btnAC.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnACActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 6;
    gridBagConstraints.ipady = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel8.add(btnAC, gridBagConstraints);

    jLabel19.setText("A");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
    jPanel8.add(jLabel19, gridBagConstraints);

    jPanel6.setLayout(new java.awt.BorderLayout());

    jLabel22.setText("I");
    jPanel6.add(jLabel22, java.awt.BorderLayout.NORTH);

    jLabel23.setText("E");
    jPanel6.add(jLabel23, java.awt.BorderLayout.SOUTH);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    jPanel8.add(jPanel6, gridBagConstraints);

    btnStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/interfaccia/button.png"))); // NOI18N
    btnStart.setText("PA");
    btnStart.setToolTipText("Avviamento");
    btnStart.setBorderPainted(false);
    btnStart.setContentAreaFilled(false);
    btnStart.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnStart.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
    btnStart.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnStartActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    jPanel8.add(btnStart, gridBagConstraints);

    jPanel5.setLayout(new java.awt.BorderLayout());

    btnMode.setIcon(new javax.swing.ImageIcon(getClass().getResource("/interfaccia/handle.png"))); // NOI18N
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("interfaccia/Bundle_interfaccia"); // NOI18N
    btnMode.setToolTipText(bundle.getString("Modalità")); // NOI18N
    btnMode.setBorderPainted(false);
    btnMode.setContentAreaFilled(false);
    btnMode.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnMode.setMargin(new java.awt.Insets(0, 0, 0, 0));
    btnMode.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
    btnMode.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        rdManualInstrActionPerformed(evt);
      }
    });
    jPanel5.add(btnMode, java.awt.BorderLayout.CENTER);

    jButton1.setText("A");
    jButton1.setToolTipText(bundle.getString("Automatica")); // NOI18N
    jButton1.setBorderPainted(false);
    jButton1.setContentAreaFilled(false);
    jButton1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    jButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        rdAutoActionPerformed(evt);
      }
    });
    jPanel5.add(jButton1, java.awt.BorderLayout.LINE_START);

    jButton2.setText("I");
    jButton2.setToolTipText(bundle.getString("Manuale_Istruzioni")); // NOI18N
    jButton2.setBorderPainted(false);
    jButton2.setContentAreaFilled(false);
    jButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        rdManualInstrActionPerformed(evt);
      }
    });
    jPanel5.add(jButton2, java.awt.BorderLayout.PAGE_START);

    jButton3.setText("M");
    jButton3.setToolTipText(bundle.getString("Manuale_Microistruzioni")); // NOI18N
    jButton3.setBorderPainted(false);
    jButton3.setContentAreaFilled(false);
    jButton3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jButton3.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        rdManualMicroinstrActionPerformed(evt);
      }
    });
    jPanel5.add(jButton3, java.awt.BorderLayout.LINE_END);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    jPanel8.add(jPanel5, gridBagConstraints);

    jPanel4.add(jPanel8, java.awt.BorderLayout.NORTH);

    lblDesktopPicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/interfaccia/HMR-SimNotes-sss.png"))); // NOI18N
    jPanel4.add(lblDesktopPicture, java.awt.BorderLayout.CENTER);

    jPanel2.add(jPanel4, java.awt.BorderLayout.CENTER);

    add(jPanel2, java.awt.BorderLayout.WEST);
  }// </editor-fold>//GEN-END:initComponents

  private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
    fireChange(FLAG_START);
}//GEN-LAST:event_btnStartActionPerformed

  private void btnExternalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExternalActionPerformed
    external=btnExternal.isSelected();
    fireChange(FLAG_EXT);
}//GEN-LAST:event_btnExternalActionPerformed

  private void btnACActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnACActionPerformed
    AC=btnAC.isSelected();
    fireChange(FLAG_AC);
}//GEN-LAST:event_btnACActionPerformed

  private void rdManualMicroinstrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdManualMicroinstrActionPerformed
    mode=Macchina.MANUAL_MICRO_MODE;
    _setmode(Macchina.MANUAL_MICRO_MODE);
    fireChange(FLAG_MODE);
}//GEN-LAST:event_rdManualMicroinstrActionPerformed

  private void rdManualInstrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdManualInstrActionPerformed
    mode=Macchina.MANUAL_INSTR_MODE;
    _setmode(Macchina.MANUAL_INSTR_MODE);
    fireChange(FLAG_MODE);
}//GEN-LAST:event_rdManualInstrActionPerformed

  private void rdAutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdAutoActionPerformed
    mode=Macchina.AUTOMATIC_MODE;
    _setmode(Macchina.AUTOMATIC_MODE);
    fireChange(FLAG_MODE);
}//GEN-LAST:event_rdAutoActionPerformed

  private void loadfile(File f){
    NumberFileNastro fa;
    try{
      fa = new NumberFileNastro(f);
    }catch(FileNotFoundException e){
      System.err.println(""+f+bundle_interfaccia.getString(":_File_not_found!!"));
      return;
    }
    
    byte nn;
    while(((nn=fa.read())&AdattatoreEntrata.EOT)==0)
      nastro.add(nastro.size(),new Byte(nn));
    
  }
  
  
  public int getTM(){return TM;}
  public short getTI(){return TI;}
  public boolean getAC(){return AC;}
  public boolean getExternal(){return external;}
  public int getMode(){return mode;}
  
  public void setVI(final int aa){
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _setvi(aa);
      }
    });
  }
  
  public void setRUNNING(final boolean b){
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _setRUN(b);
      }
    });
  }

  public void setTelescrivente(final MRTeletypePanel u){
      jPanel3.removeAll();
      jPanel3.add(u,BorderLayout.CENTER);
      jPanel3.setVisible(true);
  }
  
  private void _setvi(int a){
    for(int cx=0;cx<18;cx++)viA[cx].setSelected(MRUtils.bit(a,cx));
  }
  
  private void _setRUN(boolean b){
    chkIsRunning.setSelected(b);
  }
  
  private void _updatetm(){
    TM=0;
    for(int cx=0;cx<18;cx++){
       TM<<=1;
       TM|=tmA[17-cx].isSelected()?1:0;
    }
  }
  
    private void _updateti(){
    TI=0;
    for(int cx=0;cx<15;cx++){
      TI<<=1;
      TI|=tiA[14-cx].isSelected()?1:0;
    }
  }
    
  private int TM=0;
  private volatile short TI=0;
  private int mode=Macchina.MANUAL_INSTR_MODE;
  private boolean AC=false;
  private boolean external=false;
  private DefaultListModel nastro= new DefaultListModel();
    
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JCheckBox btnAC;
  private javax.swing.JCheckBox btnExternal;
  private javax.swing.JButton btnMode;
  private javax.swing.JButton btnStart;
  private javax.swing.JCheckBox chkIsRunning;
  private javax.swing.JCheckBox chkTI0;
  private javax.swing.JCheckBox chkTI1;
  private javax.swing.JCheckBox chkTI10;
  private javax.swing.JCheckBox chkTI11;
  private javax.swing.JCheckBox chkTI12;
  private javax.swing.JCheckBox chkTI13;
  private javax.swing.JCheckBox chkTI14;
  private javax.swing.JCheckBox chkTI2;
  private javax.swing.JCheckBox chkTI3;
  private javax.swing.JCheckBox chkTI4;
  private javax.swing.JCheckBox chkTI5;
  private javax.swing.JCheckBox chkTI6;
  private javax.swing.JCheckBox chkTI7;
  private javax.swing.JCheckBox chkTI8;
  private javax.swing.JCheckBox chkTI9;
  private javax.swing.JCheckBox chkTM0;
  private javax.swing.JCheckBox chkTM1;
  private javax.swing.JCheckBox chkTM10;
  private javax.swing.JCheckBox chkTM11;
  private javax.swing.JCheckBox chkTM12;
  private javax.swing.JCheckBox chkTM13;
  private javax.swing.JCheckBox chkTM14;
  private javax.swing.JCheckBox chkTM15;
  private javax.swing.JCheckBox chkTM16;
  private javax.swing.JCheckBox chkTM17;
  private javax.swing.JCheckBox chkTM2;
  private javax.swing.JCheckBox chkTM3;
  private javax.swing.JCheckBox chkTM4;
  private javax.swing.JCheckBox chkTM5;
  private javax.swing.JCheckBox chkTM6;
  private javax.swing.JCheckBox chkTM7;
  private javax.swing.JCheckBox chkTM8;
  private javax.swing.JCheckBox chkTM9;
  private javax.swing.JCheckBox chkVI0;
  private javax.swing.JCheckBox chkVI1;
  private javax.swing.JCheckBox chkVI10;
  private javax.swing.JCheckBox chkVI11;
  private javax.swing.JCheckBox chkVI12;
  private javax.swing.JCheckBox chkVI13;
  private javax.swing.JCheckBox chkVI14;
  private javax.swing.JCheckBox chkVI15;
  private javax.swing.JCheckBox chkVI16;
  private javax.swing.JCheckBox chkVI17;
  private javax.swing.JCheckBox chkVI2;
  private javax.swing.JCheckBox chkVI3;
  private javax.swing.JCheckBox chkVI4;
  private javax.swing.JCheckBox chkVI5;
  private javax.swing.JCheckBox chkVI6;
  private javax.swing.JCheckBox chkVI7;
  private javax.swing.JCheckBox chkVI8;
  private javax.swing.JCheckBox chkVI9;
  private javax.swing.JButton jButton1;
  private javax.swing.JButton jButton2;
  private javax.swing.JButton jButton3;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel10;
  private javax.swing.JLabel jLabel11;
  private javax.swing.JLabel jLabel12;
  private javax.swing.JLabel jLabel13;
  private javax.swing.JLabel jLabel14;
  private javax.swing.JLabel jLabel15;
  private javax.swing.JLabel jLabel16;
  private javax.swing.JLabel jLabel17;
  private javax.swing.JLabel jLabel18;
  private javax.swing.JLabel jLabel19;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel20;
  private javax.swing.JLabel jLabel21;
  private javax.swing.JLabel jLabel22;
  private javax.swing.JLabel jLabel23;
  private javax.swing.JLabel jLabel25;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JLabel jLabel4;
  private javax.swing.JLabel jLabel5;
  private javax.swing.JLabel jLabel6;
  private javax.swing.JLabel jLabel7;
  private javax.swing.JLabel jLabel8;
  private javax.swing.JLabel jLabel9;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JPanel jPanel2;
  private javax.swing.JPanel jPanel3;
  private javax.swing.JPanel jPanel4;
  private javax.swing.JPanel jPanel5;
  private javax.swing.JPanel jPanel6;
  private javax.swing.JPanel jPanel8;
  private javax.swing.JLabel lblDesktopPicture;
  private javax.swing.ButtonGroup modalitaGroup;
  // End of variables declaration//GEN-END:variables

  public void setTM(final int a) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _settm(a);
      }
    });
    
  }
  private void _settm(int a){
    for(int cx=0;cx<18;cx++)tmA[cx].setSelected(MRUtils.bit(a,cx));
    TM=a;  
  }

  
  public void updateMEM(){}
  
  
  public void setTI(final short i) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _setti(i);
      }
    });
  }
  private void _setti(short i){
    for(int cx=0;cx<15;cx++)tiA[cx].setSelected(MRUtils.bit(i,cx));
    TI=i;    
  }

  
  public void setAC(final boolean a) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _setac(a);
      }
    });
  }
  private void _setac(boolean a){
    btnAC.setSelected(a);
    AC=a;
  }

  
  public void setExternal(final boolean e) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _setexternal(e);
      }
    });
  }
  private void _setexternal(boolean e){
    btnExternal.setSelected(e);
    external=e;    
  }

  
  public void setMode(final int m) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _setmode(m);
      }
    });
  }
  private void _setmode(int m){
    switch(m){
      case Macchina.AUTOMATIC_MODE:
        //rdAuto.setSelected(true);
        btnMode.setIcon(handle_left);
        jPanel5.repaint();
        mode=m;
        break;
      default:
      case Macchina.MANUAL_INSTR_MODE:
        //rdManualInstr.setSelected(true);
        btnMode.setIcon(handle_center);
        jPanel5.repaint();
        mode=Macchina.MANUAL_INSTR_MODE;
        break;
      case Macchina.MANUAL_MICRO_MODE:
        //rdManualMicroinstr.setSelected(true);
        btnMode.setIcon(handle_right);
        jPanel5.repaint();
        mode=m;
        break;  
    }
  }
    
}
